<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>在线书城-全世界最大书城-搜索</title>
    <link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="./css/commons.css">
    <link rel="stylesheet" href="./css/index.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_2466032_1guctssow9r.css">
    <script src="js/jquery.min.js"></script>
    <style>
        .to{
            width: 1000px;
            margin: 0 auto;
        }
        .to button:nth-of-type(1){
            margin-left: 50px;
        }
        #total{
            float: left;
            font-size: 18px;
            font-family: "HoloLens MDL2 Assets";
            color: red;
            padding-left: 300px;
        }
        .index:hover{
            color: red;
        }
        .classify:hover{
            color: red;
        }
    </style>
</head>
<body>
<!-- 头部开始 -->
<div class="header flux clearfix">
    <div class="container">
        <h1 class="logo l">
            <img src="./images/logo.jpeg" alt="">
        </h1>
        <ul class="shortcut">
            <li>
                <img src="./images/addr.png" alt="">
                北京
                <img src="./images/xia.png" alt="">
            </li>
            <li onclick="window.location.href='index.html'" class="index">首页</li>
            <li class="classify" onclick="location.href='classify.html'">分类</li>
            <li>
                <img src="./images/search.png" alt="">
                <input id="text_search" type="text" placeholder="搜索图书、课堂、文艺类">
                <button id="btn_search">搜索</button>
                <script>
                    $(function () {
                        $("#text_search").val(sessionStorage.getItem("name"));
                    });
                    $("#btn_search").click(function () {
                        let name=$("#text_search").val();
                        sessionStorage.setItem("name",name);
                        location.href="search.html";
                    })
                </script>
            </li>
            <li>
                <img src="./images/user.png" alt="">
                <span  id="toLogin" onclick="window.location.href='login.html'">登录</span>
            </li>
            <li>
                <img src="./images/phone.png" alt="">
                <span id="register" onclick="location.href='regist.html'">注册</span>
            </li>
            <li>
                <div class="shopcart" onclick="window.location.href='./shopcart.html'">
                    <i class="iconfont icon-gouwuche" style="font-size:20px"></i>
                    <span>购物车</span>
                    <span id="shopNum"></span>
                </div>
            </li>
        </ul>
    </div>
</div>
<!-- 头部结束 -->
<!-- 轮播图开始 -->
<div class="box">
    <img src="./images/slider3.jpg" alt="">
    <ul class="indicator">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
    <div class="leftBtn">&lt;</div>
    <div class="rightBtn">&gt;</div>
</div>
<!-- 轮播图结束 -->
<!-- 最新商品区开始 -->
<div class="hotpro container">
    <div class="title clearfix">
        <div class="first-title l">书</div>
        <div class="second-title l">搜索</div>
    </div>
    <div class="main" style="position: absolute">
        <ul id="New">
        </ul>
        <div class="to">
            <button id="to_index">首页</button>
            <button id="left_btn" value="-1">上一页</button>
            <input  id="pages" value="1" style="width: 30px">
            <button id='right_btn' value='1'>下一页</button>
            <button id="to_Last">尾页</button>
            <button id="to_page">跳转</button>
            <p id="total">共</p>
        </div>
    </div>
</div>
<!-- 最新商品去结束 -->
<!-- 底部栏开始 -->
<div class="footer flux">
    <div class="f1 container">
        <ul>
            <li>
                <div class="tb1"></div>
                <div class="tbc">品类齐全，轻松购物</div>
            </li>
            <li>
                <div class="tb2"></div>
                <div class="tbc">多仓直发，极速配送</div>
            </li>
            <li>
                <div class="tb3"></div>
                <div class="tbc">正品行货，精致服务</div>
            </li>
            <li>
                <div class="tb4"></div>
                <div class="tbc">天天低价，畅选无忧</div>
            </li>
        </ul>
    </div>
    <div class="operator"></div>
    <div class="f2 container">
        <div>
            <ul>
                <li>购物指南</li>
                <li>
                    <a href="#">购物流程</a>
                </li>
                <li>
                    <a href="#">会员介绍</a>
                </li>
                <li>
                    <a href="#">生活旅行/团购</a>
                </li>
                <li>
                    <a href="#">常见问题</a>
                </li>
                <li>
                    <a href="#">大家电</a>
                </li>
                <li>
                    <a href="#">联系客服</a>
                </li>
            </ul>
        </div>
        <div>
            <ul>
                <li>购物指南</li>
                <li>
                    <a href="#">购物流程</a>
                </li>
                <li>
                    <a href="#">会员介绍</a>
                </li>
                <li>
                    <a href="#">生活旅行/团购</a>
                </li>
                <li>
                    <a href="#">常见问题</a>
                </li>
                <li>
                    <a href="#">大家电</a>
                </li>
                <li>
                    <a href="#">联系客服</a>
                </li>
            </ul>
        </div>
        <div>
            <ul>
                <li>购物指南</li>
                <li>
                    <a href="#">购物流程</a>
                </li>
                <li>
                    <a href="#">会员介绍</a>
                </li>
                <li>
                    <a href="#">生活旅行/团购</a>
                </li>
                <li>
                    <a href="#">常见问题</a>
                </li>
                <li>
                    <a href="#">大家电</a>
                </li>
                <li>
                    <a href="#">联系客服</a>
                </li>
            </ul>
        </div>
        <div>
            <ul>
                <li>购物指南</li>
                <li>
                    <a href="#">购物流程</a>
                </li>
                <li>
                    <a href="#">会员介绍</a>
                </li>
                <li>
                    <a href="#">生活旅行/团购</a>
                </li>
                <li>
                    <a href="#">常见问题</a>
                </li>
                <li>
                    <a href="#">大家电</a>
                </li>
                <li>
                    <a href="#">联系客服</a>
                </li>
            </ul>
        </div>
        <div>
            <ul>
                <li>购物指南</li>
                <li>
                    <a href="#">购物流程</a>
                </li>
                <li>
                    <a href="#">会员介绍</a>
                </li>
                <li>
                    <a href="#">生活旅行/团购</a>
                </li>
                <li>
                    <a href="#">常见问题</a>
                </li>
                <li>
                    <a href="#">大家电</a>
                </li>
                <li>
                    <a href="#">联系客服</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="f3 container">
        <span>关于我们</span><span>|</span>
        <span>联系我们</span><span>|</span>
        <span>联系客服</span><span>|</span>
        <span>合作招商</span><span>|</span>
        <span>商家帮助</span><span>|</span>
        <span>营销中心</span><span>|</span>
        <span>English Site</span><span>|</span>
        <span>Media & IR</span>
    </div>
    <div class="f4 container">
        <span>Copyright &copy; 2020 - 2021  乐山LS.com 版权所有</span>
        <span>|</span>
        <span>消费者维权热线：4006067733经营证照</span>
        <span>|</span>
        <span>(川)网械平台备字(2020)第00004号</span>
        <span>|</span>
        <span>营业执照</span>
    </div>
</div>
<!-- 底部栏结束 -->
</body>
<script>
    let url=window.location.href;
    let pages=url.split("=")[1];
    $.ajax({
        url:"/goods/selectByName",
        type:"get",
        data:{
            "name":sessionStorage.getItem("name"),
            "pageNum":pages,
        },
        datatype:"json",
        success:function (res) {
            sessionStorage.setItem("pageAll",res.pages);
            if(typeof pages == "undefined"){
                pages=1;
            }
            $("#pages").val(pages);
            $("#total").text("共:"+$("#pages").val()+"/"+res.pages+"页");
            let datas=res.list;
            for(let i=0;i<datas.length;i++)
            {
                let goods=datas[i];
                let li=$("<li></li>");
                let a=$("<a href='detailed.html?id="+goods.id+"'>");
                let image=$("<img src='"+goods.image+"'>");
                a.append(image);
                li.append(a);
                let p1=$("<p></p>").text(goods.name);
                let p2=$("<p></p>").text(goods.description);
                let p3=$("<p></p>");
                let span1=$("<span></span>").text("￥"+goods.salesprice);
                let span2=$("<span></span>").text("￥"+goods.marketprice);
                li.append(p1);
                li.append(p2);
                p3.append(span1);
                p3.append(span2);
                li.append(p3);
                $("#New").append(li);
            }
        },
    });
    $("#to_index").click(function () {
        location.href="search.html?p=1";
    })
    $("#left_btn").click(function () {
        $("#pages").val(pages);
        location.href="search.html?p="+($("#pages").val()-1);
    })
    $("#right_btn").click(function () {
        $("#pages").val(pages);
        location.href="search.html?p="+(parseInt($("#pages").val())+1);
    })
    $("#to_Last").click(function () {
        $("#pages").val(pages);
        location.href="search.html?p="+sessionStorage.getItem("pageAll");
    })
    $("#to_page").click(function () {
        let pages=parseInt($("#pages").val());
        location.href="search.html?p="+pages;
    })
</script>
<script src="js/toLogin.js"></script>
</html>